package com.peanut.baby.model;

import com.google.gson.annotations.SerializedName;
import com.peanut.devlibrary.util.JsonUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by anonymouslystudio on 2017/8/29.
 */

public class Advice implements Serializable{

    public int userId;
    public String date;

    @SerializedName("probability")
    public String probability;
    @SerializedName("care")
    public String care;
    @SerializedName("tips")
    public String tips;

    public void parseDBCache(String content){
        try {
            JSONObject obj = new JSONObject(content);
            probability = JsonUtils.JSONString(obj,"probability");
            care = JsonUtils.JSONString(obj,"care");
            tips = JsonUtils.JSONString(obj,"tips");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public String toDBCache(){
        JSONObject obj = new JSONObject();
        try {
            obj.put("probability",probability);
            obj.put("care",care);
            obj.put("tips",tips);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return obj.toString();
    }
}
